package ocean.chinacraft.common.world.item.classify;

import net.minecraft.world.item.ArmorItem;
import net.minecraft.world.item.Item;
import net.minecraft.world.item.ItemStack;
import net.minecraftforge.eventbus.api.IEventBus;
import net.minecraftforge.registries.DeferredRegister;
import net.minecraftforge.registries.ForgeRegistries;
import net.minecraftforge.registries.RegistryObject;
import ocean.chinacraft.common.constants.Constants;
import ocean.chinacraft.common.world.item.armor.SilkNightArmor;
import ocean.chinacraft.common.world.item.armor.base.MaterialEnums;

import java.util.ArrayList;
import java.util.List;
import java.util.function.Supplier;

/**
 * 防具
 *
 * @author zhang
 * @since 2023/8/7
 */
public class ModItemArmor {

    public static final DeferredRegister<Item> ARMOR = DeferredRegister.create(ForgeRegistries.ITEMS,
            Constants.MOD_ID);

    public static final List<ItemStack> ITEMS = new ArrayList<>();

    /**
     * 夜行衣头罩
     */
    public static final RegistryObject<Item> NIGHT_CLOTHES_HEAD = register("night_clothes_head",
            () -> new SilkNightArmor(MaterialEnums.SILK_NIGHT_ARMOR, ArmorItem.Type.HELMET, new Item.Properties()));

    /**
     * 夜行衣胸衣
     */
    public static final RegistryObject<Item> NIGHT_CLOTHES_CHEST = register("night_clothes_chest",
            () -> new SilkNightArmor(MaterialEnums.SILK_NIGHT_ARMOR, ArmorItem.Type.CHESTPLATE, new Item.Properties()));

    /**
     * 夜行衣绑腿
     */
    public static final RegistryObject<Item> NIGHT_CLOTHES_LEGS = register("night_clothes_legs",
            () -> new SilkNightArmor(MaterialEnums.SILK_NIGHT_ARMOR, ArmorItem.Type.LEGGINGS, new Item.Properties()));

    /**
     * 夜行衣护腿
     */
    public static final RegistryObject<Item> NIGHT_CLOTHES_FEET = register("night_clothes_feet",
            () -> new SilkNightArmor(MaterialEnums.SILK_NIGHT_ARMOR, ArmorItem.Type.BOOTS, new Item.Properties()));

    private static <T extends Item> RegistryObject<T> register(String name, Supplier<T> item) {
        return ARMOR.register(name, item);
    }

    public static void register(IEventBus bus) {
        ARMOR.register(bus);
    }

    public static List<ItemStack> buildToolTab() {
        ITEMS.add(new ItemStack(NIGHT_CLOTHES_HEAD.get()));
        ITEMS.add(new ItemStack(NIGHT_CLOTHES_CHEST.get()));
        ITEMS.add(new ItemStack(NIGHT_CLOTHES_LEGS.get()));
        ITEMS.add(new ItemStack(NIGHT_CLOTHES_FEET.get()));
        return ITEMS;
    }
}
